

  <button onclick="doclinks(); return 0"> eLookinto Docs</button>

  <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>

  <script type="text/javascript">


  function displayDoc(i, docType)
{
 
 if (docType == 1) docType='doc';
  if (docType == 2) docType='swf';
 
  el = document.getElementById("docframe"+i);
  // alert(i);

  docId = '#' + docType + i;
  text  =  $(docId).text();
 // alert(text);
  if (text == 'View' || text =="Swf") {

    // el.style.display = "block";
    // $('#doc'+i).css('display', 'block');
    //$('#doc'+i).css('zIndex', "999");
    //$('#doc'+i).css('width', "100%");
    //$('#doc'+i).css({'display':'block','zIndex':'999', 'position':'absolute', 'top':'0px', 'left':'0px', 'width':'100%'});
     //alert(docId);
    $('#docframe'+i).css({'display':'block','zIndex':'999', 'left':'0px'});
    //el.style = 'display:block;position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:999'


     url =  $("#v"+ docType + i).val();
    $("#doc"+i).text("View");
    $("#swf"+i).text("Swf");

    $(docId).text('Hide');

   
   // alert(url);
    conv = "http://elookinto.com/elconverter/activeX.jsp?url="+url;
    //alert(conv);
    el.src = conv;
  } else
  {
    el.style.display = "none";
    $("#doc"+i).text("View");
    $("#swf"+i).text("Swf");
  }
  //$('#doc' +i).style.display = 'block';
  //
}


function doclinks()
{  
  els = document.getElementsByTagName("a");

   for (i =0; i<els.length; i++)
  {
    if (document.getElementById('doc'+i) != null )
        {
            return; // buttons already inserted.
        }
  }

  for (i =0; i<els.length; i++)
  {
    if (document.getElementById('#doc'+i) != null )
        {
            return;
        }
    href = els[i].href;
    start = href.lastIndexOf(".");
    ext = "";
    if (start >0)
    {
      ext = href.substring(start+1);
    }
    else continue;

    if (ext == "doc" || ext == "docx" || ext == "rtf" || ext == "pdf")
    /*if (els[i].href .match(/[\.doc|\.docx|\.rtf]$/))*/ {
      //alert(els[i].href);
      //button = document.createElement("button");
      //button.onclick="alert(1)";
      var section = els[i].parentNode.parentNode.parentNode;
      if ( $.browser.msie ) {
       if( $.browser.version < 8.0 ) {
           section = els[i].parentNode.parentNode;
       }
      }
      $('<button id="doc'+i+'" onclick="displayDoc('+i+', 1)">View</button>').insertBefore(els[i]);
      $('<input id="vdoc'+i+'" type=hidden />').insertBefore(els[i]);
      $('<button id="swf'+i+'" onclick="displayDoc('+i+', 2)">Swf</button>').insertBefore(els[i]);
       $('<input id="vswf'+i+'" type=hidden />').insertBefore(els[i]);
      $('#vdoc'+i).val(els[i].href);
      $('#vswf'+i).val (els[i].href+"$swf");

      $('<iframe frameborder="0" style="display:none;padding:0px;margin-left:-5px" id="docframe'+i+'" width=1200 height=1000> </iframe>').insertAfter(section);

    }
  }

 
}


$(document).ready( function()
{
  doclinks();
  setInterval('doclinks()', 2000);
  //dolinks();

});

  </script>
